﻿using System.Windows.Controls;
using System.Windows.Data;
using GlobalizationTools.Model;

namespace GlobalizationTools.ViewModel
{
    public static class DataGridColumnUtil
    {
        public static DataGridColumn GetColumn(string type, string header, int pos)
        {
            if (type == ResourceUtils.StringTypeName)
            {
                return CreateDataGridTextColumn(header, pos);
            }
            else if (type == ResourceUtils.ImageTypeName)
            {
                return CreateDataGridImageColumn(header, pos);
            }
            return null;
        }

        private static DataGridColumn CreateDataGridTextColumn(string header, int pos) {
            DataGridTextColumn column = new DataGridTextColumn();
            column.Header = header;
            column.Binding = new Binding(string.Format("Values[{0}].Value", pos));
            return column;
        }

        private static DataGridColumn CreateDataGridImageColumn(string header, int pos)
        {
            DataGridImageColumn column = new DataGridImageColumn();
            column.Header = header;
            column.Binding = new Binding(string.Format("Values[{0}].Value", pos));
            return column;
        }
    }
}
